#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200001; // 最大节点个数
vector<int> tree[MAX_N];  // MAX_N为最大顶点个数
int n;
int treeSize[MAX_N];   // 以i为根的树的规模；
// int maxSubTree[MAX_N]; // 以i为根的最大子树的规模；
int ans = 0x3f3f3f3f;

void dfs(int root, int father) {
  treeSize[root] = 1;
  int winner = 0;
  for (auto son : tree[root]) {
    dfs(son, root);
    treeSize[root] += treeSize[son];
    winner = max(winner, treeSize[son] );
  }
  winner = max(winner, n - treeSize[root] );
  ans = min(winner, ans);
}
int main() {
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int fater;
    cin >> fater;
    tree[fater].push_back(i);
  }
  dfs(1, 0);
  cout << ans;
  return 0;
}
